﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Zeus.Thunder.Core;
using System.Configuration;
using System.ServiceModel;
using System.ServiceModel.Web;
using Perseus.WCF.REST.Contract.Data;

namespace Perseus.WCF.REST.Client.Basic
{
    class EmpUpdTest : ITestCase
    {
        public void Run()
        {
            string url = ConfigurationManager.AppSettings["empUrl"];

            Console.Write("Please Input EmployeeID: ");
            string empId = Console.ReadLine();
            Console.Write("Please Input First Name: ");
            string firstName = Console.ReadLine();
            Console.Write("Please Input Last Name: ");
            string lastName = Console.ReadLine();
            Console.Write("Please Input BirthDate: ");
            string birthDate = Console.ReadLine();

            using (WebChannelFactory<IEmployeeService> wcf
                = new WebChannelFactory<IEmployeeService>(new Uri(url)))
            {
                var channel = wcf.CreateChannel();
                DbResponse result = channel.UpdateEmployee(empId, firstName, lastName, birthDate);
                if (result.Success)
                    Console.WriteLine("更新成功!");
                else
                    Console.WriteLine("更新失败!");
            }
        }
    }
}
